<template>
	<view class="pages" >
		<image v-if="Type==0" class="cententimg" src="../../../static/user/cutType1.png" mode=""></image>
		<image v-if="Type==1" class="cententimg" src="../../../static/user/cutType2.png" mode=""></image>
		<view class="bottom">
			<view class="title">
				您当前的身份是“{{Type== 1 ? '需求方' :'接单方'}}”
			</view>
			<view class="bnt" @click="bnt()">
				切换为“{{Type== 1 ? '接单方' :'需求方'}}”身份
			</view>
		</view>
	</view>
</template>

<script>
import * as user from '@/api/user.js'
import { mapMutations } from 'vuex';
	export default {
		data() {
			return {
				Type: uni.getStorageSync('Type'),
				cutShow: false,
			};
		},
		onLoad () {
		},
		methods: {
			...mapMutations(['setRoleId']),
			bnt(){
				if(this.cutShow){
					return
				}
				this.cutShow = true
				setTimeout(res=>{
					this.cutShow = false
				},3000)
				let Type =  uni.getStorageSync('Type')
				if(Type === 0) {
					Type = 1
					// let that = this
					// uni.setStorage({
					// 	key: 'link',
					// 	data: 'https://app.wanhedashuju.com/',
					// 	success: function () {
					// 		that.$tools.navigate('/pages/home/webView/index')
					// 	}
					// });
					// return
				} else {
					Type = 0
				}
				this.setRoleId(Type)
				this.disconnect()
				uni.showLoading({
					title: '切换中'
				});
				setTimeout(res=>{
					uni.hideLoading()
					uni.reLaunch({
						url: '/pages/home/index',
					});
				},2000)
			},
			disconnect() { //断开链接
				if(this.goEasy.getConnectionStatus() != 'disconnected'){
					this.goEasy.disconnect({
						onSuccess: function() {
							console.log('断开成功')
						},
						onFailed: function(error) {
							// 务必确保断开成功才允许客户退出应用，否则有可能会收到上个用户的消息。
							console.log('断开失败', error);
						}
					});
				}
			},
		}
	}
</script>

<style>
	page {
		background-color: #FFFFFF;
		height: 100%;
	}
	.pages {
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

	}
	.cententimg {
		width: 100%;
		height: 724rpx;
	}
	.bottom {
		margin-top: 172rpx;
	}
	.title {
		text-align: center;
		font-size: 40rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: bold;
		color: #FF6600;
	}
	.bnt {
		margin-top: 50rpx;
		width: 670rpx;
		height: 80rpx;
		background: #FF6600;
		border-radius: 8rpx;
		opacity: 1;
		text-align: center;
		line-height: 80rpx;
		font-size: 32rpx;
		font-weight: bold;
		color: #FFFFFF;
	}
</style>
